Close Menu
    Facebook X (Twitter) Instagram
    • Download Cisco Packet Tracer
    Facebook X (Twitter) Instagram Pinterest Vimeo
    IT Beginner
    • Home
    • Server
    • WordPress
    IT Beginner
    Home»Tips – Tricks»How to fix nginx an upstream response is buffered to a temporary file error
    Tips – Tricks

    How to fix nginx an upstream response is buffered to a temporary file error

    05/08/2017No Comments2 Mins Read

    After running Nginx for a while. You can read how I install LEMP server with Linux, Nginx, PHP-FPM, and MySQL on Centos. I got tons of warn logs from nginx on Centos an upstream response is buffered to a temporary file which I don’t like to see. The problem is that I didn’t set fastcgi_buffer for nginx so nginx gives out warn upstream response is buffered to a temporary file /var/cache/nginx/fastcgi_temp/.

    To view Nginx’s error log

    # cat /var/log/nginx/error.log

    There are many an upstream response is buffered to a temporary file /var/cache/nginx/fastcgi_temp/ warn logs from forum.namhuy.net. The warning messages means response was buffered to disk. It’s not that important problem but I don’t want to get any kind of error. You can disable disk buffering with “fastcgi_max_temp_file 0″ in your .conf file or set fastcgi_buffers and fastcgi_buffer_size

    2014/05/10 03:56:06 [warn] 1483#0: *144520 an upstream response is buffered to a temporary file /var/cache/nginx/fastcgi_temp/5/78/0000003785 while reading upstream, client: 54.86.133.62, server: forum.namhuy.net, request: "GET /style.php?id=1&lang=en&sid=69475f2bd936d3e96ef925ce546a79c9 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "forum.namhuy.net", referrer: "http://forum.namhuy.net/viewforum.php?f=3&sid=74d333aafeefe7332a418519e8b03277"
    2014/05/10 03:56:28 [warn] 1483#0: *144518 an upstream response is buffered to a temporary file /var/cache/nginx/fastcgi_temp/6/78/0000003786 while reading upstream, client: 54.86.133.62, server: forum.namhuy.net, request: "GET /style.php?id=1&lang=en HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "forum.namhuy.net", referrer: "http://forum.namhuy.net/posting.php?mode=post&f=3&sid=69475f2bd936d3e96ef925ce546a79c9"
    2014/05/10 03:57:40 [warn] 1483#0: *144673 an upstream response is buffered to a temporary file /var/cache/nginx/fastcgi_temp/7/78/0000003787 while reading upstream, client: 198.204.244.53, server: forum.namhuy.net, request: "GET /style.php?id=1&lang=en&sid=b70a193e6808fb2183ac1c0228097227 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "forum.namhuy.net", referrer: "http://forum.namhuy.net/viewforum.php?f=2&sid=74d333aafeefe7332a418519e8b03277"
    2014/05/10 03:58:06 [warn] 6276#0: *37 an upstream response is buffered to a temporary file /var/cache/nginx/fastcgi_temp/1/00/0000000001 while reading upstream, client: 198.204.244.53, server: forum.namhuy.net, request: "GET /style.php?id=1&lang=en HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "forum.namhuy.net", referrer: "http://forum.namhuy.net/viewtopic.php?f=2&t=2&sid=b70a193e6808fb2183ac1c0228097227"

    To disable fastcgi disk buffering

    # nano /etc/nginx/conf.d/default.conf

    and add this line to location ~ \.php$ { fastcgi configurations }

    fastcgi_max_temp_file 0;

    You should have something like this

         location ~ \.php$ {

            root           /usr/share/nginx/html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_max_temp_file 0;
            include        fastcgi_params;
        }

    To set fastcgi_buffer_size and fastcgi_buffer

    # nano /etc/nginx/conf.d/default.conf

    and add this two lines to location ~ \.php$ { fastcgi configurations }

    fastcgi_buffer_size 4K;
    fastcgi_buffers 64 4k;
    You should have something look like this
        location ~ \.php$ {
            root           /usr/share/nginx/html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_max_temp_file 0;
            fastcgi_buffer_size 4K;
            fastcgi_buffers 64 4k;
            include        fastcgi_params;
        }
    Fastcgi buffer will store responses up to 4K+64*4K=260K in memory.
    fastcgi_buffer
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleOptimize WordPress with Nginx
    Next Article What Makes Linux the Most Adopted Operating System

    Related Posts

    Tips – Tricks

    Optimize WordPress with Nginx

    04/08/2017
    Security

    How to secure Apache HTTP Web Server

    29/07/2017
    Tips – Tricks

    Browse web in linux via terminal with w3m and xterm

    29/07/2017
    Subscribe
    Notify of
    guest

    guest

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    0 Comments
    Oldest
    Newest Most Voted
    Inline Feedbacks
    View all comments
    Tags
    apache centos Centos 6 cuda Desktop Environment dual boot environment featured gnome GUI hostname hosts intel kernel kill lamp server lemp server life MariaDB netflix nginx nvidia password php-fpm phpmyadmin pids processes s.m.a.r.t Security session solid state drive ssd ssh ssh server tag 1 tag 2 Ubuntu upgrade varnish VirtualBox VNC Server web server window manager wordpress xfce
    Facebook X (Twitter) Instagram Pinterest

    Type above and press Enter to search. Press Esc to cancel.

    wpDiscuz